﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;

namespace BLL
{
	public class BLThietBi
	{

		public static IEnumerable<ThietBi> GetAll()
		{
			return Generic.GetAll<ThietBi>();
		}
		public static bool Insert(ThietBi tb)
		{
			return Generic.Insert<ThietBi>(tb);
		}
		public static int Delete(ThietBi tb)
		{
			return Generic.DeleteByCondition<ThietBi>(tb1 => tb1.MaTB == tb.MaTB);
		}
		public static int DeleteAll(IEnumerable<ThietBi> ps)
		{
			return Generic.DeleteByCondition<ThietBi>(tb => ps.Where(x => x.MaTB == tb.MaTB).Count() == 1);
		}
		public static int Update(ThietBi tb)
		{
			return Generic.EditByCondition<ThietBi>(k => k.MaTB == tb.MaTB, k =>
			{
				k.MaTB = tb.MaTB;
				k.NgayLapRap = tb.NgayLapRap;
				k.NgayNhap = tb.NgayNhap;
				k.NhanHieu = tb.NhanHieu;
				k.TenTB = tb.TenTB;
				k.TinhTrang = tb.TinhTrang;
				k.XuatXu = tb.XuatXu;
			});
		}
		public static IEnumerable<ThietBi> FindByCondition(Func<ThietBi, bool> func)
		{
			return Generic.FindByCondition<ThietBi>(func);
		}
	}
}
